<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>加减乘除</title>
	</head>
	<body>
		<p>数字1：</p>
		<input id="n1" type="text">
		<p>数字2：</p>
		<input id="n2" type="text>">
		<!--按钮的点击事件，执行add函数-->
		<br/>
		<br/>
		<input id="btn" type="button" value="求和" onclick="add()">
		<input id="btn2" type="button" value="求减" onclick="jian()">
		<input id="btn3" type="=button" value="求乘" onclick="cheng()">
		<input id="btn4" type="button" value="求除" onclick="chu()">
		<p id="sum"></p>
		<script>
			function add(){
				var num1=document.getElementById('n1');
				var num2=document.getElementById('n2');
				var sum=document.getElementById('sum');
				var result=num1.value+num2.value;
			    result=Number(num1.value)+Number(num2.value);
			    sum.innerHTML=(num1.value)+"+"+(num2.value)+"="+result;
			}
			function jian(){
				var num1=document.getElementById('n1');
				var num2=document.getElementById('n2');
				var sum=document.getElementById('sum');
			    result=Number(num1.value)-Number(num2.value);
			    var result=num1.value-num2.value;
			    sum.innerHTML=(num1.value)+"-"+(num2.value)+"="+result;
			}
			function cheng(){
				var num1=document.getElementById('n1');
				var num2=document.getElementById('n2');
				var sum=document.getElementById('sum');
				var result=num1.value*num2.value;
			    result=Number(num1.value)*Number(num2.value);
			    sum.innerHTML=(num1.value)+"*"+(num2.value)+"="+result;
			}
			function chu(){
				var num1=document.getElementById('n1');
				var num2=document.getElementById('n2');
				var sum=document.getElementById('sum');
				var result=num1.value\num2.value;
			    result=Number(num1.value)\Number(num2.value);
			    sum.innerHTML=(num1.value)+"/"+(num2.value+"="+result);
			}
		</script>
	</body>
</html>
